package com.lh.java.basic.recurrence;

/**
 ************************************************
 ** Module : 汉诺塔
 ** Date: 2012-8-1  Time: 下午06:10:10 
 ** Author lh 
 ************************************************ 
 */
public class TowersTest {	
	static int nDisks = 3;
	static int step = 0;

	public static void main(String[] args) {
		doTowers(nDisks, 'A', 'B', 'C');
		System.out.println("step = "+step);
	}
	
	public static void doTowers(int topN,char from,char inter,char to) {
		if(1==topN){
			step++;
			System.out.println("Disk "+topN+" from "+from+" to "+to);
		}
		else {			
			step++;
			doTowers(topN-1,from,to,inter);
			System.out.println("Disk "+topN+" from "+from+" to "+to);
			doTowers(topN-1,inter,from,to);
			
		}
	}  
	
	
}
